package com.example.myapplication

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity


class MainActivity : AppCompatActivity() {
    @SuppressLint("WrongViewCast")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val linearLayout= LinearLayout(this)
        linearLayout.orientation= LinearLayout.VERTICAL

        val text=TextView(this)
        text.layoutParams=ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT)
        text.textSize=30F
        text.text=getString(R.string.textView)
        linearLayout.addView(text)


        val button= Button(this)
        button.width=ViewGroup.LayoutParams.MATCH_PARENT
        button.height=ViewGroup.LayoutParams.WRAP_CONTENT
        button.text=getString(R.string.button)
        linearLayout.addView(button)

        setContentView(linearLayout)
        val imageView = ImageView(this)
        imageView.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
        imageView.setImageResource(R.drawable.flag)
        linearLayout.addView(imageView)


//        enableEdgeToEdge()
//        setContentView(R.layout.activity_main)
//        setContentView(R.layout.activity_main)
//        val button: Button = findViewById<Button>(R.id.button)
//        var text: TextView = findViewById<TextView>(R.id.textView)
//
        button.setOnClickListener {
            text.text =resources.getString(R.string.clicked)
        }

    }
}
